<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/rights' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-table :data="fy" border stripe>
        <!-- <el-table-column type="index" label="#"></el-table-column> -->
        <el-table-column label="权限名称" prop="authName"></el-table-column>
        <el-table-column label="路径" prop="path"></el-table-column>
        <el-table-column label="权限等级" prop="level">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level == '0'"> 一级 </el-tag>
            <el-tag type="success" v-else-if="scope.row.level == '1'">
              二级
            </el-tag>
            <el-tag v-else type="warning"> 三级 </el-tag>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        layout="total, prev, pager, next"
        :total="total"
        :page-size="10"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      rightsList: [],
      fy: [],
      total: 0,
      pagesize: 1,
    };
  },
  created() {
    this.getRightsList();
  },
  methods: {
    async getRightsList() {
      let { data: res } = await this.$http.get("rights/list");
      this.rightsList = res.data;
      // console.log(this.rightsList);
      this.fy = this.rightsList.slice(0, 10);
      this.total = this.rightsList.length;
      // console.log(this.fy);
    },
    handleCurrentChange(page) {
      // console.log(page);
      let a = (page - 1) * 10;
      this.fy = this.rightsList.slice(a, 10 + a);
      // console.log(a);
    },
  },
};
</script>
<style lang="less">
</style>